package dao.interfaces;

import java.util.List;

import dao.interfaces.IBase;


/**
 * <desc>DaoOperationFacade are used to provide information about the operations of database </desc>
 * <responsibility>Represents the pattern DAO</responsibility>
 * <coperation>All classes that need to work with database</coperation>
 * @version  0.2
 * Create  18-03-2009
 * Author Alfred Oliver
 *
 * Updated  07-05-2013
 * Revision Eduard Escrihuela
*/
public interface IDAOFacade {
		
	/**
	  * Procedure that starts the transaction
	  * {Pre: There is an open connection to the database}.
	  * {Post: has initiated the transaction}.
	  * @throws DataException if there isn't a connection to the database.
	  * @throws DataException if there is an error to start the transaction.
	  */
	public void beginTrans();
	
	/**
	  * Procedure that end the transaction accepting updates.
	  * {Pre: There is an open connection to the database}.
	  * {Post: End the transaction}.
	  */
	public void commitTrans();
	 
	/**
	  * Procedure that end the transaction not accepting updates.
	  * {Pre: There is an open connection to the database}.
	  * {Post: End the transaction}.
	  */
	public void rollbackTrans();  
	
	/**
	 * Procedure that closed the connection to database. 
	 * {Pre: there isn't more references to object in memory}.
	 * {Post: Closed the connection to database}. 
	 */
	//public void finalize();

	/**
	 * Result of the operation. 
	
	 */
	public boolean isOperationResult();
	 
	/**
	 * Persist object. 
	 * {Pre: The object no exist}.
	 * {Post: The object is persist. 
	 */
	public void insert (IBase obj);
	
	/**
	 * Update object. 
	 * {Pre: The object exist}.
	 * {Post: The object is update. 
	 */
	public void update(IBase obj);
	
	/**
	 * Remove object. 
	 * {Pre: The object exist}.
	 * {Post: The object is remove. 
	 */
	public void delete(IBase obj);
	
	/**
	 * Find object by primary key. 
	 * {Pre: Primary key of object}.
	 * {Post: return object if exist}. 
	 */
	public IBase findObjectByPK (Class<?extends IBase> entityClass, long id );
	
	/**
	 * Find object by field unique description. 
	 * {Pre: Field description}.
	 * {Post: return object if exist}. 
	 */
	public IBase findObjectByDescription (Class<?extends IBase> entityClass, String description);
	
	/**
	 * Find objects by some criterion. 
	 * {Pre: Some criterion, if there aren't some criterion, List all object}.
	 * {Post: return List objects if exist}. 
	 */
	public List<?extends IBase> getObjectList (Class<?extends IBase> entityClass, String criteria);		
	
	/**
	 * Enable /disable logging  
	 * {Pre: Logging may be initially enabled or disabled
	 * {Post: Enable or disable logging}. 
	 */
	public void enableLog(Boolean enabled);		
	
	
	
}
